﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SelectKeyBoard
{
    /// <summary>
    /// 选择项节点信息
    /// </summary>
    public class XNode
    {
        /// <summary>
        /// 同级别节点列表中的唯一编号
        /// </summary>
        public int Id { get; set; }
      
        /// <summary>
        /// 指示节点的深度或级别代号
        /// </summary>
        public int Level { get; set; }
      
        /// <summary>
        /// 索引名称
        /// </summary>
        public string IndexName { get; set; }

        /// <summary>
        /// 节点名称
        /// </summary>
        public string Key { get; set; }

        /// <summary>
        /// 节点UI控件代码
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 节点业务代码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 父节点
        /// </summary>
        public XNode Parent { get; set; }

        /// <summary>
        /// 子节点列表
        /// </summary>
        public List<XNode> ChildNodes { get; set; } = new List<XNode>();

        public bool IsRoot
        {
            get 
            {
                return Level == 1;
            }
        }

        public bool IsLeaf { get; set; }

        public XNode()
        {
        }

        public XNode(int level, string key, string value)
        {
            Level = level;
            Key = key;
            Value = value;
        }
    }
}
